<template>
  <div>
    <div class="app-container clearfix pageHeader">
      <div class="header fl">{{$route.meta.title}}</div>
    </div>

    <div class="app-container margin-content padding-content">
      <el-form
        :model="dataForm"
        ref="dataForm"
        label-width="80px">

        <el-row :gutter="48">
          <el-col :sm="24" :md="8">
            <el-form-item label="所属码头" prop="portId">
              <treeselect
                placeholder="请选择"
                :options="options"
                :disable-branch-nodes="true"
                value-consists-of="LEAF_PRIORITY"
                :close-on-select="true"
                :open-on-click="true"
                v-model="dataForm.portId"/>
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="8">
            <el-form-item label="作业日期" prop="time">
              <el-date-picker
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                unlink-panels
                value-format="yyyy-MM-dd"
                v-model="dataForm.time"
                :picker-options="pickerOptions"
                style="width: 100%;"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="8">
            <el-form-item label="集装箱号" prop="contNo">
              <el-input clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="8">
            <el-form-item label="异常类型" prop="isDeal">
              <el-select v-model="dataForm.isDeal" placeholder="请选择" style="width: 100%;">
                <el-option key="0" label="已处理" value="0"></el-option>
                <el-option key="1" label="未处理" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :sm="24" :md="8">
            <el-form-item label="处理情况" prop="isDeal">
              <el-select v-model="dataForm.isDeal" placeholder="请选择" style="width: 100%;">
                <el-option key="0" label="已处理" value="0"></el-option>
                <el-option key="1" label="未处理" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <div style="text-align: right">
          <el-button type="primary">查询</el-button>
        </div>
      </el-form>
    </div>


    <div class="app-container margin-content padding-content">
      <el-table
        :key="tableKey"
        :data="tableData"
        v-loading="loading"
        element-loading-text="正在加载..."
        style="width: 100%;">

        <el-table-column label="集装箱号"></el-table-column>
        <el-table-column label="进出口"></el-table-column>
        <el-table-column label="作业类型"></el-table-column>
        <el-table-column label="作业时间"></el-table-column>
        <el-table-column label="重吉"></el-table-column>
        <el-table-column label="集装箱尺寸"></el-table-column>
        <el-table-column label="堆场位置"></el-table-column>
        <el-table-column label="超时天数"></el-table-column>
        <el-table-column label="处理状态"></el-table-column>
        <el-table-column label="操作"  fixed="right">
          <template slot-scope="scope">
            <a>明细</a>
            <divider type="vertical"></divider>
            <a>处理情况</a>
          </template>
        </el-table-column>
      </el-table>

      <div class="pagination-container align-right" v-show="tableData.length > 0">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="dataForm.pageNum"
          :page-sizes="pageSizes"
          :page-size="dataForm.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
  // api
  import {getPortTree} from '@/api/port'
  // utils
  import {pickerOptions, getLately} from '@/utils'
  import {page} from '@/utils/page'
  import {modifyObj} from '@/utils/tools'
  // components
  import Treeselect from '@riophae/vue-treeselect'

  const time = getLately(0)

  export default {
    name: 'zoneWaring',
    data() {
      return {
        tableKey: 0,
        tableData: [],
        loading: false,
        dataForm: {
          time: time,
          portId: null,
          isDeal: ''
        },
        total: 0,
        pageSizes: page.pageSizes,
        pickerOptions: {
          shortcuts: pickerOptions
        },
        options: []
      }
    },
    created() {
      this._getPortTree()
    },
    methods: {
      _getPortTree() {
        getPortTree().then((res) => {
          this.options = modifyObj(res.data.data)
        })
      },
      handleSizeChange(val) {
        this.dataForm.pageSize = val
      },
      handleCurrentChange(val) {
        this.dataForm.pageNum = val
      }
    },
    components: {
      Treeselect
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped="scope">

</style>
